package com.example.builder;

import com.example.builder.item.Item;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description TODO
 * @Date 2021/10/27 9:10
 * @Author ZhangJi
 * @Version 1.0
 */
public class Meal {

  private List<Item> items = new ArrayList<>();

  /**
   * @Description 添加单个食物种类进套餐
   * @param singleItem burger或drink的实现类
   */
  public void addItem(Item singleItem){
    items.add(singleItem);
  }

  /**
   * @Description 计算套餐的总价
   * @return 套餐的总价
   */
  public float getCost(){
    float[] arrayCost= new float[1];
    arrayCost[0] = 0.0f;
    items.forEach(o-> arrayCost[0] += o.price());
    return arrayCost[0];
  }

  /**
   * @Description 显示套餐内食物
   */
  public void showItems(){
    items.forEach(o->{
      System.out.println(o.name());
      System.out.println(o.pack().showPack());
      System.out.println(o.price());
    });
  }

}
